home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / codeop.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  2KB  |  89 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import __future__
  5. _features = [ getattr(__future__, fname) for fname in __future__.all_feature_names ]
  6. __all__ = [
  7.     'compile_command',
  8.     'Compile',
  9.     'CommandCompiler']
  10. PyCF_DONT_IMPLY_DEDENT = 512
  11.  
  12. def _maybe_compile(compiler, source, filename, symbol):
  13.     for line in source.split('\n'):
  14.         line = line.strip()
  15.         if line and line[0] != '#':
  16.             break
  17.             continue
  18.     elif symbol != 'eval':
  19.         source = 'pass'
  20.     
  21.     err = None
  22.     err1 = None
  23.     err2 = None
  24.     code = None
  25.     code1 = None
  26.     code2 = None
  27.     
  28.     try:
  29.         code = compiler(source, filename, symbol)
  30.     except SyntaxError:
  31.         err = None
  32.  
  33.     
  34.     try:
  35.         code1 = compiler(source + '\n', filename, symbol)
  36.     except SyntaxError:
  37.         err1 = None
  38.  
  39.     
  40.     try:
  41.         code2 = compiler(source + '\n\n', filename, symbol)
  42.     except SyntaxError:
  43.         err2 = None
  44.  
  45.     if code:
  46.         return code
  47.     
  48.     if not code1 and repr(err1) == repr(err2):
  49.         raise SyntaxError, err1
  50.     
  51.  
  52.  
  53. def _compile(source, filename, symbol):
  54.     return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT)
  55.  
  56.  
  57. def compile_command(source, filename = '<input>', symbol = 'single'):
  58.     return _maybe_compile(_compile, source, filename, symbol)
  59.  
  60.  
  61. class Compile:
  62.     
  63.     def __init__(self):
  64.         self.flags = PyCF_DONT_IMPLY_DEDENT
  65.  
  66.     
  67.     def __call__(self, source, filename, symbol):
  68.         codeob = compile(source, filename, symbol, self.flags, 1)
  69.         for feature in _features:
  70.             if codeob.co_flags & feature.compiler_flag:
  71.                 self.flags |= feature.compiler_flag
  72.                 continue
  73.             self
  74.         
  75.         return codeob
  76.  
  77.  
  78.  
  79. class CommandCompiler:
  80.     
  81.     def __init__(self):
  82.         self.compiler = Compile()
  83.  
  84.     
  85.     def __call__(self, source, filename = '<input>', symbol = 'single'):
  86.         return _maybe_compile(self.compiler, source, filename, symbol)
  87.  
  88.  
  89.